﻿; obj := InputBox("Please enter x,y.", "Loop Click")

; if(obj.Result!="OK"){
;     ExitApp
; }

; arr :=StrSplit(obj.Value,",")
; if(arr.Length!=2){
;     MsgBox("Input format error!")
;     if (A_IsCompiled){
;         Run Format('"{1}" /force', A_ScriptFullPath)
;     }else{
;         Run Format('"{1}" /force "{2}"', A_AhkPath, A_ScriptFullPath)
;     }
;     ExitApp
; }

MsgBox("Press F12 to start`nPress F11 to stop")

SetTimer WatchCursor, 100

WatchCursor() {
    ; MouseGetPos &xpos, &ypos, &id, &control
    ; ToolTip
    ; (
    ;     "ahk_id " id "
    ;     ahk_class " WinGetClass(id) "
    ;     " WinGetTitle(id) "
    ;     Control: " control
    ; )
    global
    MouseGetPos &xpos, &ypos
    ToolTip("x: " xpos " y: " ypos)
}

F12:: {
    SetTimer WatchCursor, 0
    ToolTip()
    loop {
        if GetKeyState("F11", "P") {
            MsgBox("stop")
            break
        }

        Click xpos, ypos
        Sleep 200
    }
    SetTimer WatchCursor, 100
}
